package org.ch03.job.test09;

/**
 * @author XCH
 * @date 2025 - 03 - 30
 */
public abstract class Keeper<T extends Animal> {
    public abstract void feed(T animal);

    public void patrol(T animal) {
        System.out.println("开始巡查" + animal.getClass().getSimpleName());

        // 使用反射检查睡眠状态
        SleepStatus sleepStatus = animal.getClass().getAnnotation(SleepStatus.class);
        if (sleepStatus != null) {
            System.out.println("睡眠状态：" + sleepStatus.value());
            if("失眠".equals(sleepStatus.value())){
                System.out.println("分发安眠药给" + animal.getClass().getSimpleName());
            }

        }
    }

    public void healthCheck(T animal) {
        System.out.println("对" + animal.getClass().getSimpleName() + "进行体检");

        // 使用反射检查健康状态
        HealthStatus healthStatus = animal.getClass().getAnnotation(HealthStatus.class);
        if (healthStatus != null) {
            System.out.println("健康状态：" + healthStatus.value());
            if ("差".equals(healthStatus.value())) {
                System.out.println("需要特别照看！");
            }
        }
    }
}
